﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Webinars.aspx.cs" Inherits="WebSite.Webinars" %>



<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <link  rel="stylesheet" type="text/css" href="Styles/jquery-ui-1.9.2.css"/>
    
    <script type="text/javascript" src="Scripts/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="Scripts/jquery.json-2.4.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.9.2.js"></script>
   
    <style type="text/css">
        body {
	        font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
	        font-size: 62.5%;
        }
        
        td
        {
            vertical-align:top;
        }
        .webinarSection
        {
            padding: 2px;
            margin: 2px; 
        }
        
        .futureWebinarSection
        {
            border-width: thin;
            border-style: solid;
            padding: 2px;
            margin: 2px; 
            padding-right: 20px;
        }
        
        .webinarTitle
        {
            font-weight: bold;
        }
        
        .bulletFree
        {
            list-style-type: none;
            list-style-image: none;
        }
        
        .lp-block    {   }
        
        .action-block
        {
            margin-left:2px;
            margin-right:2px;
            float:right;
            background:#eee;
        }
        
        .vote-box-div
        {
            background-image: url("/Images/voteBackground.gif");
            margin-left:2px;
            margin-right:2px;
            width:30px;
            height:20px;
            text-align: center;
            overflow:hidden;
            border:0;
            display:inline;
        }
        
        .vote-box
        {
            margin-left:2px;
            margin-right:2px;
            width:20;
            height:20;
            border:0;
            display:inline;
        }
        
        .vote-frame
        {
            float: right;
        }
        
        .loading
        {
            background-image:url("/Images/loading-1.gif");
            width: 100%;
            height:100;
        }
                      
        #live-preview-display   { background:#eee; padding:10px; margin:10px 20px 20px 20px}
        #lp-name { font-weight:bold; }
        #lp-comment { padding-top:10px; font-style:italic; line-height:19px; }
        
   </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
   <div id="main" >
   <table >
    <tr>
        <td id="exSheet" class="futureWebinarSection" style="vertical-align:top;display:none;">
            <ul class="bulletFree">
                <li class="bulletFree">
                    <h1>Webinars on site</h1>
                </li>
                <li class="bulletFree">
                    <h1 id="resultFoundLable"  style="font-size:9pt;"> 
                        <span>Present </span>
                        <span id="viewRange"></span>

                        <span id="moreResults" style="display:inline; font-size:8pt; float:right;">
                            <a href="javascript:loadMore();" >See more...</a>
                        </span>
                    </h1>
   
                    <div id="exitingWebinars">
                    </div>
                </li>
            </ul>
        </td>
        <td id="fSheet" class="futureWebinarSection" style="width:200px; vertical-align:top;display:none;">
            <ul class="bulletFree" >
                <li id="scheduleFutureWebinar" class="bulletFree" style="display:none;float:right;">
                    <div id="scheduleFutureWebinarDiv">
                    </div>
                </li>
                <li id="futureHeader" class="bulletFree">
                    <h1>Whats New</h1>
                </li>
                <li class="bulletFree">
                    <h1 id="H1"  style="font-size:9pt;"> 
                        <span id="moreFutureResults" style="display:inline; font-size:8pt;">
                            <a href="javascript:loadMoreFutureWebinars();" >See more...</a>
                        </span>
                    </h1>
   
                    <div id="futureWebinars">
                    </div>
                </li>
            </ul>
        </td>
    </tr>
    </table>
    <br />

    <div id="dialogs" style="display:none">
        <div id="AddQuestionDialog" style="display:none; overflow:hidden;">
            <textarea id="quesContent" cols="2" rows="2" style="width:370px; height: 150px;" ></textarea>
            <iframe id="captchaQuestionsValidatorFrame" src="CaptchaValidator.aspx" frameborder="0" height="200px" width="98%" scrolling="no"></iframe> 
        </div>

        <div id="commentsDialog" style="display:none; overflow:hidden;">
            <div id="historyComments" class="futureWebinarSection" style="overflow:auto; height:80px;">
            </div>
            <textarea id="newCommentContent" cols="2" rows="2" style="width:370px; height: 50px;" ></textarea>
            <iframe id="captchaCommentsValidatorFrame" src="CaptchaValidator.aspx" frameborder="0" height="200px" width="98%" scrolling="no"></iframe> 
        </div>

        <div id="scheduleWebinarDialog" style="display:none; overflow:hidden;">
            <div >
                <table style="width:100%; ">
                    <tr>
                        <td style="width:5px; text-align:center; padding-top:2px;">*</td>
                        <td>Name:</td>
                        <td><input id="weName" type="text"  /></td>
                    </tr>
                    <tr>
                        <td style="width:5px; text-align:center; padding-top:2px;">*</td>
                        <td>Schedule On:</td>
                        <td><input type="text" id="weDatepicker" /></td>
                    </tr>
                    <%--<tr>
                        <td>URI:</td>
                        <td><input id="webinarURI" type="text" style="width:95%;"/></td>
                    </tr>--%>
                    <tr>
                        <td style="width:5px;"></td>
                        <td>Description:</td>
                        <td><textarea id="weDesc" cols="2" rows="2" style="width:95%; height: 70px;" ></textarea></td>
                    </tr>
                </table>
                <iframe id="captchaWebinarValidatorFrame" src="CaptchaValidator.aspx" frameborder="0" height="200px" width="98%" scrolling="no" ></iframe> 
            </div>
        </div>

   </div>
   </div>  
   
    
<script type="text/javascript" >
    var futurePageNum = 1;
    var futurePageSize = 10;

    var extPageNum = 1;
    var extPageSize = 10;

    var currentUser = null;

    function doCaptchaValidate(iframe, onValidate) {
        document.getElementById(iframe).contentWindow["validate"](onValidate);
    }

    function scheduleWebinar() {
        $('#weDatepicker').datepicker("setDate", null);
        $("#weName").val("");
        $("#weDesc").val("");

        $("#scheduleWebinarDialog").dialog({ title: "Schedule Webinar",
            height: 430,
            width: 400,
            modal: true,
            position: 'center',
            overlay: { opacity: 0.5, background: 'black' },
            open: function (event, ui) {
                $("#captchaWebinarValidatorFrame").attr("src", "CaptchaValidator.aspx");
            },
            close: function( event, ui ) {
                $("#captchaWebinarValidatorFrame").attr("src", "javascript:empty");
            },
            buttons: {
                "Schedule": function () {
                    doCaptchaValidate ("captchaWebinarValidatorFrame", function () { 
                                                                            saveWebinar();
                                                                            $("#scheduleWebinarDialog").dialog("close");
                                                                        });
                },
                "Cancel": function () { $("#scheduleWebinarDialog").dialog("close"); }
            }
        });
    }

    function saveWebinar() {
        var wd = $("#weDatepicker").datepicker('getDate')
        var wname = $("#weName").val();
        var wdesc = $("#weDesc").val();

        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/ScheduleWebinar",
            data: $.toJSON({ webinarName: wname, scheduled: wd, description: wdesc }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action scheduleWebinar : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    buildResultsSection(res.d.Data, true);
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }
    
    function loadMoreFutureWebinars() {
        futurePageNum++;
        loadFuture();
    }

    function loadMore() {
        extPageNum++;
        loadExiting();
    }

    function saveQuestion(webinarId) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/AddQuestion",
            data: $.toJSON({ webinarId: webinarId, content: $("#quesContent").val() }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action saveQuestion : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    addQuestionSection($("#commentsDiv_" + webinarId), res.d.Data);
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function getQuestions(webinarObj, divObj) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/GetQuestions",
            data: $.toJSON({ webinarId: webinarObj.ID }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action getQuestions : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    fillQuestionSection(webinarObj.ID, divObj, res.d.Data);
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function createDateAsUTC(date) {
        return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
    }

    function fromDateString(str) {
        var res = str.match(/\/Date\((\d+)(?:([+-])(\d\d)(\d\d))?\)\//);
        if (res == null)
            return new Date(NaN); // or something that indicates it was not a DateString
        var time = parseInt(res[1], 10);
        if (res[2] && res[3] && res[4]) {
            var dir = res[2] == "+" ? -1 : 1,
            h = parseInt(res[3], 10),
            m = parseInt(res[4], 10);
            time += dir * (h * 60 + m) * 60000;
        }
        return createDateAsUTC(new Date(time));
    }

    function markQuestionAsAnswered(adminAnswerId, questionId) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/MarkAsAnswerd",
            data: $.toJSON({ questionId: questionId }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action markQuestionAsAnswered : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    $(adminAnswerId).hide();
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function voteOnQuestion(voteDivId, questionId, thumbsUp) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/Vote",
            data: $.toJSON({ questionId: questionId, thumbsUp: thumbsUp }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action voteOnQuestion : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    $(voteDivId).hide();
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function showComments(questionId) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/GetComments",
            data: $.toJSON({ questionId: questionId }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action showComments : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    showCommentsDialog(questionId, res.d.Data);
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function saveComment(questionId, content) {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/AddComment",
            data: $.toJSON({ questionId: questionId, content: content }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action saveComment : " + res.d.NativeError.Message);
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function addCommentSection(divObj, commentObj) {
        var outerDiv = $(document.createElement("div"));
        outerDiv.attr("id", "live-preview-display");
        outerDiv.attr("class", "lp-block");
        outerDiv.attr("style", "margin-top:10px; margin-bottom:10px; background-color:#DADADA;");

        divObj.append(outerDiv);

        var nameDiv = $(document.createElement("div"));

        nameDiv.attr("id", "lp-name");
        nameDiv.text(commentObj.UserName + " comments ( " + fromDateString(commentObj.CreationDate).toLocaleString() + " ):");
        outerDiv.append(nameDiv);

        var commentDiv = $(document.createElement("div"));

        commentDiv.attr("id", "lp-comment");
        outerDiv.attr("style", "margin-left:20px;");

        commentDiv.text(commentObj.Content);
        outerDiv.append(commentDiv);
    }

    function showCommentsDialog(questionId, comments) {
        $("#historyComments").text("");
        $("#newCommentContent").val("");

        for (var i = 0; i < comments.length; i++) {
            addCommentSection($("#historyComments"), comments[i])
        }

        $("#commentsDialog").dialog({ title: "Comments",
            height: 460,
            width: 400,
            modal: true,
            position: 'center',
            overlay: { opacity: 0.5, background: 'black' },
            open: function (event, ui) {
                $("#captchaCommentsValidatorFrame").attr("src", "CaptchaValidator.aspx");
            },
            close: function (event, ui) {
                $("#captchaCommentsValidatorFrame").attr("src", "javascript:empty");
            },
            buttons: {
                "Comment": function () {
                    doCaptchaValidate("captchaCommentsValidatorFrame", function () {
                        saveComment(questionId, $("#newCommentContent").val());
                        $("#commentsDialog").dialog("close");
                    });
                },
                "Cancel": function () { $("#commentsDialog").dialog("close"); }
            }
        });
    }

    

    function addVoteBox(actionDiv, questionObj) {
        //vote box
        var voteDiv = $(document.createElement("div"));
        voteDiv.attr("id", "vote_" + new Date().getTime());
        voteDiv.attr("class", "vote-frame");

        actionDiv.append(voteDiv);

        var a = $(document.createElement("a"));
        a.attr("href", "javascript:voteOnQuestion(" + voteDiv.attr("id") + ", " + questionObj.ID + ", false)");
        voteDiv.append(a);

        var img = $(document.createElement("img"));
        img.attr("class", "vote-box");
        img.attr("title", "vote against");
        img.attr("alt", "vote against");
        img.attr("src", "/Images/voteAgainst.gif");
        a.append(img);

        a = $(document.createElement("a"));
        a.attr("href", "javascript:voteOnQuestion(" + voteDiv.attr("id") + ", " + questionObj.ID + ", true)");
        voteDiv.append(a);

        img = $(document.createElement("img"));
        img.attr("class", "vote-box");
        img.attr("title", "vote for");
        img.attr("alt", "vote for");
        img.attr("src", "/Images/voteFor.gif");
        a.append(img);

        //vote box - till here
    
    }

    function addQuestionSection(divObj, questionObj) {
        var outerDiv = $(document.createElement("div"));
        outerDiv.attr("id", "live-preview-display");
        outerDiv.attr("class", "lp-block");

        divObj.prepend(outerDiv);

        var nameDiv = $(document.createElement("div"));
       
        nameDiv.attr("id", "lp-name");
        nameDiv.text(questionObj.UserName + " asks ( "+ fromDateString(questionObj.CreationDate).toLocaleString() + " ):");
        outerDiv.append(nameDiv);

        var commentDiv = $(document.createElement("div"));

        commentDiv.attr("id", "lp-comment");
        commentDiv.text(questionObj.Content);
        outerDiv.append(commentDiv);

        

        var actionDiv = $(document.createElement("div"));
        actionDiv.attr("class", "action-block");
        actionDiv.attr("style", "width:100%; margin-top:10px;");
        actionDiv.attr("id", "lp-actions");

        outerDiv.append(actionDiv);

        if (questionObj.AllowVotes) {
            addVoteBox(actionDiv, questionObj);
        }

        var actionDiv2 = $(document.createElement("div"));
        actionDiv2.attr("class", "action-block");
        actionDiv2.attr("style", "float:left");

        actionDiv2.attr("id", "lp-actions");

        actionDiv.append(actionDiv2);

        var a = $(document.createElement("a"));
        a.attr("class", "action-block");
        //a.text("Comments");
        a.attr("href", "javascript:showComments(" + questionObj.ID + ")");

        var img = $(document.createElement("img"));
        img.attr("class", "vote-box");
        img.attr("title", "Comments");
        img.attr("alt", "Comments");
        img.attr("style", "width:15px; height:15px;");
        img.attr("src", "/Images/comments.ico");
        a.append(img);

        actionDiv2.append(a);

        if (currentUser.IsAdmin && questionObj.Active) {
            a = $(document.createElement("a"));
            a.attr("id", "adminAnswer_" + new Date().getTime());
            a.attr("class", "action-block");
            a.text("Mark Answered");
            a.attr("href", "javascript:markQuestionAsAnswered(" + a.attr("id") + ", " + questionObj.ID + ")");

            actionDiv2.append(a);
        }

        var tmpDiv = $(document.createElement("div"));
        tmpDiv  .attr("style", "margin:1px; height:15px;");
        tmpDiv.html("&nbsp;");
        outerDiv.append(tmpDiv);
    }

    function navigateToAddQuestion(webinarId) {
        $("#quesContent").val("");

        $("#AddQuestionDialog").dialog({ title: "Write Question",
            height: 450,
            width: 400,
            modal: true,
            position: 'center',
            overlay: { opacity: 0.5, background: 'black' },
            open: function (event, ui) {
                $("#captchaQuestionsValidatorFrame").attr("src", "CaptchaValidator.aspx");
            },
            close: function (event, ui) {
                $("#captchaQuestionsValidatorFrame").attr("src", "javascript:empty");
            },
            buttons: {
                "OK": function () {
                    doCaptchaValidate("captchaQuestionsValidatorFrame", function () {
                        saveQuestion(webinarId);
                        $("#AddQuestionDialog").dialog("close");
                    });
                },
                "Cancel": function () { $("#AddQuestionDialog").dialog("close"); }
            }
        });
    }

    function fillQuestionSection(webinarId, divObj, questionsArray) {
        divObj.html("");
        for (var i = 0; i < questionsArray.length; i++) {
            addQuestionSection(divObj, questionsArray[i])
        }

        var outerDiv = $(document.createElement("h3"));
        outerDiv.attr("id", "live-preview-display");
        outerDiv.attr("class", "lp-block");

        divObj.append(outerDiv);

        var btnAdd = $(document.createElement("a"));
        btnAdd.text("Add your own question...");
        btnAdd.attr("href", "javascript:navigateToAddQuestion(" + webinarId + ");");
        btnAdd.attr("style", "fornt-size:11pt; texte-align:center;");

         //$("<input type='button' value='add question' style='font-size:6pt; display:inline; margin-left:5px; float:right' ></input>");
        outerDiv.append(btnAdd);
    }


    function addQuestionsHintSection(result, divObj) {
        if (currentUser) {
            var innerDiv = $(document.createElement("div"));
            divObj.append(innerDiv);

            var btnShow = $("<img src='/Images/plus.png' title='See Questions' alt='See Questions'  style='width:20px; height:20px;'></input>");
            innerDiv.append(btnShow);

            var commentsDiv = $(document.createElement("div"));
            commentsDiv.attr("id", "commentsDiv_" + result.ID);
            commentsDiv.attr("class", "futureWebinarSection");
            commentsDiv.hide();
            innerDiv.append(commentsDiv);

            btnShow.attr("command", "open");
            btnShow.click(function () {
                if (btnShow.attr("command") == "open") {
                    btnShow.attr("command", "close");
                    btnShow.attr("src", "/Images/minus.png");
                    commentsDiv.show();
                    getQuestions(result, commentsDiv);
                }
                else {
                    btnShow.attr("command", "open");
                    btnShow.attr("src", "/Images/plus.png");
                    commentsDiv.hide();
                }
            });

        }
    }

    function emptyFunc() {
    }

    function buildResultsSection(webinarObj, isFuture) {
        var section = isFuture ? $("#futureWebinars") : $("#exitingWebinars");
        
        var outerdiv = $(document.createElement("div"));
        outerdiv.attr("class", "webinarSection");

        var h3 = $(document.createElement("h3"))
        h3.attr("class", "webinarTitle");

        var a = $(document.createElement("a"));
        a.text(webinarObj.Name);
        if (webinarObj.URI) {
            a.attr("href", webinarObj.URI);
            a.attr("target", "blank");
        }
        else {
            a.attr("href", "javascript:emptyFunc()");
        }
        
        h3.append(a);
        
        var div = $(document.createElement("div"));

        section.append(outerdiv);
        outerdiv.append(h3);
        outerdiv.append(div);

        div.append($("<br/>"));

        var span = $(document.createElement("span"));
        var sPrefix = (isFuture ? "Intend to be published on: " : "Published on: ");

        span.text(sPrefix + fromDateString(webinarObj.Scheduled).toDateString());
        span.attr("style", "font-size:6pt;");

        div.append(span);

        var p = $(document.createElement("p"));
        p.text(webinarObj.Description);

        div.append(p);

        if (!isFuture) {
            addQuestionsHintSection(webinarObj, div);
        }
    }

    function buildResultsSections(results, isFuture) {
        for (var i = 0; i < results.length; i++) {
            buildResultsSection(results[i], isFuture);
        }
    }

    function buildResultsChain(webinarsData, isFuture) {
        currentUser = webinarsData.CurrentUser;

        if (isFuture) {
            if (currentUser && currentUser.IsAdmin) {
                var a = $(document.createElement("a"));
                a.attr("style", "font-size:8pt; float:right;");
                a.attr("href", "javascript:scheduleWebinar()");
                $("#scheduleFutureWebinarDiv").append(a);

                var img = $(document.createElement("img"));
                img.attr("class", "vote-box");
                img.attr("title", "Schedule Webinar");
                img.attr("alt", "Schedule Webinar");
                img.attr("src", "/Images/addWebinar.png");
                a.append(img);

                $("#scheduleFutureWebinar").show();
            }
        }

        buildResultsSections(webinarsData.Data, isFuture);

        if (!isFuture) {
            if (webinarsData.TotalCount <= 0) {
                $("#viewRange").text("There are no results");
            }
            else {
                $("#viewRange").text((webinarsData.FromIndex > 1 ? 1 : webinarsData.FromIndex) + " - " + (webinarsData.ToIndex > webinarsData.TotalCount ? webinarsData.TotalCount : webinarsData.ToIndex) + " from " + webinarsData.TotalCount);
            }
        }

        var moreResultObj = isFuture ? $("#moreFutureResults") : $("#moreResults");
        if (webinarsData.TotalCount <= webinarsData.ToIndex) {
            moreResultObj.hide();
        }
        else {
            moreResultObj.show();
        }

    }


    function loadExiting() {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/GetWebinars",
            data: $.toJSON({ pageNum: extPageNum, pageSize: extPageSize }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action loadExiting : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    buildResultsChain(res.d, false);
                    $("#exSheet").show();
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    function loadFuture() {
        $.ajax({
            type: "POST",
            url: "/WebServices/UIBeckendService.asmx/GetFutureWebinars",
            data: $.toJSON({ pageNum: futurePageNum, pageSize: futurePageSize }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (res) {
                if (res.d.Status == 2) {
                    alert("error in action loadFuture : " + res.d.NativeError.Message);
                }
                else if (res.d.Status == 1) {
                    buildResultsChain(res.d, true);
                    $("#fSheet").show();
                }
            },
            complete: function (xhr, status) {
                if (status == "error") {
                    alert(xhr.responseText);
                }
            }
        });
    }

    $(function () {
        loadExiting();
        loadFuture();

        $("#weDatepicker").datepicker();
    });
</script> 

</asp:Content>
